﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace School.WebPages.Research
{
    public partial class Activity : System.Web.UI.Page
    {
        TechnologySchoolEntities db = new TechnologySchoolEntities();
        private string itemid = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "科研动态";

            itemid = Request.QueryString["itemid"];

            if (!Page.IsPostBack)
            {
                int count = db.Article.Where(a => a.SubMenu.Categories == 6).Count();
                anp_activity.RecordCount = count;
                BindData();
            }
        }

        private void BindData()
        {
            rep_activity.DataSource = DAL.PagerHelper.GetPagerData("Article", "ArticleID,Content,UpdateTime", "UpdateTime",
                anp_activity.PageSize, anp_activity.CurrentPageIndex, "Categories=6 and IsChecked=1");
            rep_activity.DataBind();
        }

        protected void anp_activity_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

        protected void rep_activity_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                if (itemid == ((HiddenField)e.Item.FindControl("hlID")).Value)
                {
                    ((Label)e.Item.FindControl("lblCon")).CssClass = "red";
                }
            }
        }
    }
}
